<template>
	<view>
		<u-field v-model="mobile" label="工作经历" placeholder="请填写"></u-field>
		<u-field v-model="mobile1" label="最高学历" placeholder="请填写"></u-field>
		<u-field v-model="mobile2" label="现居住地" placeholder="请填写"></u-field>
		<u-field v-model="mobile3" label="期望职位" placeholder="请填写"></u-field>
		<u-field v-model="mobile4" label="教育经历" placeholder="请填写"></u-field>

		<u-field v-model="mobile5" type="textarea" label="个人简介" placeholder="请填写"></u-field>
		<button @click="xiu" style="margin: 20rpx;">{{title}}</button>
	</view>
</template>

<script>
	import api from 'commer/apiURL.js'
	export default {
		data() {
			return {
				base: api.baseurl,
				reactive: [],
				mobile: '',
				mobile2: '',
				mobile3: '',
				mobile4: '',
				mobile5: '',
				mobile1: '',
				title:'新建简历',
				id:''
			}
		},
		onLoad(options) {
			this.id = options.id
			this.getgern(options.id)
		},
		methods: {
			getgern(id) {
				this.$get(this.base + '/prod-api/api/job/resume/queryResumeByUserId/' + id).then((res) => {
					if(res.data == null){
						this.title = '新建简历'
						uni.setNavigationBarTitle({
							title:'新建个人简历'
						})
					}else{
						this.title = '修改简历'
						uni.setNavigationBarTitle({
							title:'修改个人简历'
						})
						this.reactive = res.data
						this.mobile = res.data.experience
						this.mobile1 = res.data.mostEducation
						this.mobile2 = res.data.address
						this.mobile3 = res.data.positionId
						this.mobile4 = res.data.education
						this.mobile5 = res.data.individualResume
					}
				})
			},
			xiu() {
				if(this.title == '修改简历'){
					this.$put(this.base + '/prod-api/api/job/resume', {
						"id": this.reactive.id,
						"mostEducation": this.mobile1,
						"education": this.mobile4,
						"address": this.mobile2,
						"experience": this.mobile,
						"individualResume": this.mobile5
					}).then((res) => {
						if (res.code == 200) {
							uni.showToast({
								title: "修改成功",
							})
						} else {
							uni.showToast({
								title: res.msg,
								icon: 'none'
							})
							this.getgern(this.id)
						}
					})
				}else{
					//新建简历
					this.$post(this.base + '/prod-api/api/job/resume', {
						"id": this.reactive.id,
						"mostEducation": this.mobile1,
						"education": this.mobile4,
						"address": this.mobile2,
						"experience": this.mobile,
						"individualResume": this.mobile5
					}).then((res) => {
						if (res.code == 200) {
							uni.showToast({
								title: "新建成功",
							})
						} else {
							uni.showToast({
								title: res.msg,
								icon: 'none'
							})
							this.getgern(this.id)
						}
					})
				}
				
			}
		}
	}
</script>

<style>

</style>
